<?php

namespace app\api\service;

use EasyWeChat\Factory;
use EasyWeChat\Kernel\Exceptions\HttpException;

/**
 * 部门管理-服务类
 * Class DeptService
 * @package app\admin\service
 */
class WechatService extends BaseService
{
    /**
     * 构造函数
     *
     * DeptService constructor.
     */
    protected $app;
    public function __construct()
    {
        parent::__construct();
    }

    public function jssdk()
    {
        try {
            $officialAccountConfig = config('wechat.official_account.default');
            $this->app = Factory::officialAccount($officialAccountConfig);
            $jssdk = $this->app->jssdk->buildConfig([
                'updateAppMessageShareData', 'updateTimelineShareData'
            ], $debug = false, $beta = false, $json = true);

            return $this->success($jssdk);
        } catch (HttpException $exception) {
            return $this->error($exception->getMessage());
        }
    }
}